<script setup lang="ts">
// import dataJson from "./data.json";
import Java from "./editor.vue";
import { onMounted, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import { generator } from "@/api/generator";
const route = useRoute();
const router = useRouter();
const activeName = ref("Entity");
const height = ref("");
const data = ref([]);
// data.value = dataJson;
const tableName = route.params.tableName;
generator(tableName, 1)
  .then(res => {
    data.value = res;
  })
  .catch(() => {
    router.go(-1);
  });
onMounted(() => {
  height.value = document.documentElement.clientHeight - 180 + "px";
});
</script>

<template>
  <el-tabs v-model="activeName" type="card" class="flex-col">
    <el-tab-pane
      v-for="(item, index) in data"
      :key="item.name"
      :lazy="true"
      :label="item.name"
      :name="item.name"
    >
      <Java :value="item.content" :index="index" :height="height" />
    </el-tab-pane>
  </el-tabs>
</template>
